<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Delivers_m extends FOX_Model
{

	function __construct ()
	{
		parent::__construct();
        $this->config->load('userset');//用户积分
	}

  //查询所有的物流公司
    public function get_all_delivers_comenpty(){
        $query=$this->db->select('*')->from('deliver_companys')->get();
        return $query->result_array();
    }
    //添加物流
    public function add_deliver($data){
        $this->db->insert('delivers',$data);
        if($this->db->affected_rows() > 0){
            return $this->db->insert_id();
        }else{
            return false;
        }
    }
    //查询单挑的快递公司
    public function get_delivers_by_id($id){
        $query =$this->db->select('*')->from('deliver_companys')->where('id',$id)->get();
        return $query->row_array();
    }
    //根据order_id查询单挑物流信息
    public function get_deliver_by_order_id($id){
        $query = $this->db->select('*')->from('delivers')->where('order_id',$id)->get();
        return $query->row_array();
    }
    //修改发货物流信息
    public function save_deliver($id,$data){
        $this->db->where('DELIVER_id',$id);
        $this->db->update('delivers', $data);
        return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
    }
}
